<?php

/**
 * Element form.
 *
 * @package    appcemhti
 * @subpackage form
 * @author     Steve Cancès
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class ElementForm extends BaseElementForm
{
  public function configure()
  {
      $this->widgetSchema['id_element'] = new sfWidgetFormInput();
      $this->widgetSchema['nom']->setLabel("Nom de l'élément");
      $this->widgetSchema['id_element']->setLabel("Numéro de l'élément");
      
      $this->validatorSchema['nom'] = new sfValidatorString(array('required' => true, 'max_length' => 32), array('required' => 'Champ obligatoire.', 'max_length' => '"%value%" est trop long (%max_length% lettres maximum).'));
      
      $this->validatorSchema['id_element'] = new sfValidatorAnd(
              array(
                  new sfValidatorNumber(array('required' => true, 'max' => 99999), array('max' => '"%value%" est trop grand (%max% maximum).')),
                  new sfValidatorDoctrineUnique(array("model" => "element", "column" => "id_element"))
              ), array(), array(
                  'required' => 'Champ obligatoire.'
              )
        );
      
      $this->validatorSchema->setPreValidator(
      new sfValidatorAnd(array(
        new sfValidatorDoctrineUnique(array('model' => 'element', 'column' => array('id_element'))),
        new sfValidatorDoctrineUnique(array('model' => 'element', 'column' => array('id_element'))),
      ))
    );
      
  }
}
